import 'package:flutter/material.dart';

class MyGird extends StatelessWidget {
  const MyGird({super.key});

  @override
  Widget build(BuildContext context) {
    return GridView(
      //固定个数
      // gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
      //   crossAxisCount: 2,
      //   //子组件间距
      //   mainAxisSpacing: 10,
      //   //子组件间距
      //   crossAxisSpacing: 10,
      //   //宽高比
      //   childAspectRatio: 1 / 4,
      // ),
      gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
        maxCrossAxisExtent: 200,
        //子组件间距
        mainAxisSpacing: 10,
        //子组件间距
        crossAxisSpacing: 10,
        //宽高比
        childAspectRatio: 4 / 1,
      ),
      children: [
        Container(color: Colors.red),
        Container(color: Colors.green),
        Container(color: Colors.blue),
        Container(color: Colors.yellow),
        Container(color: Colors.purple),
        Container(color: Colors.orange),
        Container(color: Colors.pink),
        Container(color: Colors.brown),
        Container(color: Colors.teal),
        Container(color: Colors.cyan),
        Container(color: Colors.lightBlue),
        Container(color: Colors.lightGreen),
      ],
    );
  }
}
